<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head> 
   <meta charset="UTF-8">
   <%@ include file="/WEB-INF/views/include/head.jsp"%>
   <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
   <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
   <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
   <script src="${ctxStatic}/js/layer.js"></script>
   <script src="${ctxStatic}/js/style.js"></script>
   <script src="${ctxStatic}/jquery-barcode/jquery-barcode.js" type="text/javascript"></script>
   <c:set value="<%=ResourcesUtil.getConfig(\"outbound_status_not_all\")%>" var="inventoryStatusNotAll" />
   <c:set value="<%=ResourcesUtil.getConfig(\"outbound_status_all\")%>" var="inventoryStatusAll" />
   <script type="text/javascript">   
	$(document).ready(function(){		
		$("#inventoryRequestBarCodeDiv").empty().barcode($("#ostockBarCode").val(), "code128",{barWidth:2, barHeight:30,showHRI:false});
	});
	
	/* 刷新明细  */
    function requestOutDetailsList() {
  	    var id = $("#id").val();
    	param={"id":id};
    	$.post("${ctx}/slopwork/outbound/show",param,function(result){ 
        	$("#tableRequestDetails").html($(callBackHtml(result)).find("#tableRequestDetails").html());
        	tryToCgStatus();
        },'html');
	}
    
 	function closeThisWin() {
 		window.parent.frames[0].searchListForm();
		closeWin();
	}
 	
 	 /* 试图更改入库状态  */
    function tryToCgStatus() {
		var length = $(".realQuantity").length;
		var sumResult = parseFloat(0);
		var reResult = parseFloat(0);
		for (var i = 0; i < length; i++) {
			var realQuantity = $(".realQuantity")[i].innerHTML;
			if (realQuantity==""||realQuantity==null) {
				return;
			}
			realQuantity = realQuantity.replace(/,/g,"");
			sumResult += parseFloat(realQuantity);
		}
		for (var i = 0; i < length; i++) {
			var requestOutQuantity = $(".requestOutQuantity")[i].innerHTML;
			if (requestOutQuantity==""||requestOutQuantity==null) {
				requestOutQuantity = "0";
			}
			requestOutQuantity = requestOutQuantity.replace(/,/g,"");
			reResult += parseFloat(requestOutQuantity);
		}
		var inventoryStatus = "";
		if (reResult>sumResult) {
			inventoryStatus = "${inventoryStatusNotAll}";
		}else if(reResult<=sumResult){
			inventoryStatus = "${inventoryStatusAll}";
		}
		var id = "${slopworkOutbound.id}";
		var params = {"id":id,"outboundStatus":inventoryStatus};
		$.post("${ctx}/slopwork/outbound/changeStatus",params,function(result){    
			window.parent.frames[0].searchListForm();
			closeWin();
        },'html');
	}
	</script>
</head>
<body>
<div class="layerHeader clearfix">
	<p class="headerTitle">创建出库</p>
    <div class="headerButton clearfix">
        <!-- 取消 -->
        <button onclick="closeThisWin()">关闭</button>
    </div>
</div>
<form id="inputForm" method="post">
<input type="hidden" id="id" name="id" value="${slopworkOutbound.id}"/>
    <c:set value="<%=ResourcesUtil.getConfig(\"clothes_out_category_samply\")%>" var="varClothesOutSamply" />
    <c:set value="<%=ResourcesUtil.getConfig(\"clothes_out_category_order\")%>" var="varClothesOutOrder" />
<div class="smOrderBox">
    <div class="items clearfix">
        <div class="col-33 clearfix" id="divInventoryRequestNo">
            <!-- 出库单号 -->
            <p class="tit"><spring:message code="SlopworkOutrequest_show_inventoryRequestNo" /></p>
            <p>${slopworkOutbound.outboundRequestNo}</p>
        </div>
        <div class="col-33 clearfix">
            <!-- 出库类别 -->
            <p class="tit"><spring:message code="SlopworkOutrequest_show_inventoryCategory" /></p>
            <p>${fns:getDictName(slopworkOutbound.outboundCategory)}</p>
        </div>
    </div>
    <div class="items clearfix">
       <c:choose>
           <c:when test="${slopworkOutbound.outboundCategory eq varClothesOutSamply}">
                <div class="col-33 clearfix">
            <!-- 样品需求订单 -->
            <p class="tit" style="width:75px;"><spring:message code="customer_styleNo_choose" /></p>
            <p>${slopworkOutbound.samplyRequestNo}</p>
        </div>
           </c:when>
           <c:otherwise>
               <div class="col-33 clearfix" id="divCustomerContractNo">
                   <!-- 合同编号 -->
                   <p class="tit"><spring:message code="SlopworkOutrequest_show_order" /></p>
                   <p>${slopworkOutbound.contractNo}</p>
               </div>
           </c:otherwise>
       </c:choose>
        <div class="col-33 clearfix" id="divStyleId">
            <!-- 款式 -->
            <p class="tit"><spring:message code="SlopworkOutrequest_show_style" /></p>
            <p>${slopworkOutbound.ocustomerStyleNo}</p>
        </div>
    </div>
</div>
<div class="tableArea">
    <div class="tableScrollSm" style="overflow:auto;width:925px;height:440px;">
        <table cellpadding="0" class="tableHead">
            <thead>
            <tr>
                <!-- 操作 -->
                <th class="tab-ddcz">操作</th>
                <!-- 客户订单号 -->
                <th><p class="width-250px"><spring:message code="slopworkInRequest_show_list_customerContractNo" /></p></th>
                <!-- 颜色-->
                <th><p class="width-120px"><spring:message code="slopworkInRequest_show_list_color" /></p></th>
                <!-- 尺码 -->
                <th><p class="width-120px"><spring:message code="slopworkInRequest_show_list_size" /></p></th>
                <!-- 订单数量 -->
                <th><p class="width-120px"><spring:message code="slopworkInRequest_show_list_indentQuantity" /></p></th>
                <!-- 申请出库数量 -->
                <th><p class="width-120px"><spring:message code="SlopworkOutrequest_list_requestQuantity" /></p></th>
                <!-- 出库数量-->
                <th><p class="width-120px"><spring:message code="inventory_requestex_list_realQuantity" /></p></th>
            </tr>
            </thead>
        </table>
        <table cellpadding="0" class="tableBody" id="tableRequestDetails">
        <c:if test="${not empty slopworkOutbound.clothsOutDetailsList}">
            <tbody>
            <c:forEach items="${slopworkOutbound.clothsOutDetailsList}" var="OutrequestDetailsInfo" varStatus="status">
            <tr>
                <!-- 操作 -->
                <td class="tab-ddcz"><img src="${ctxStatic}/images/btn-bj.png" onclick="popup('960px','519px','${ctx}/slopwork/outbound/inventoryClothesDetail?outRequestDetailId=${OutrequestDetailsInfo.outRequestDetailId}&slopworkOutbound=${slopworkOutbound.styleId }')" height="30" width="30"></td>
                <!-- 客户订单号 -->
                <td><p class="width-250px">${OutrequestDetailsInfo.customerContractNo}</p></td>
                <!-- 颜色-->
                <td><p class="width-120px">${OutrequestDetailsInfo.styleColor}</p></td>
                <!-- 尺码 -->
                <td><p class="width-120px">${fns:getDictName(OutrequestDetailsInfo.styleSize)}</p></td>
                <!-- 订单数量 -->
                <td><p class="width-120px"><fmt:formatNumber value="${OutrequestDetailsInfo.oindentQuantity}" pattern="#,##0"/></p></td>
                <!-- 申请出库数量-->
                <td><p class="width-120px requestOutQuantity"><fmt:formatNumber value="${OutrequestDetailsInfo.requestOutQuantity}" pattern="#,##0.###"/></p></td>
                <!-- 实际出库数量-->
                <td><p class="width-120px realQuantity"><fmt:formatNumber value="${OutrequestDetailsInfo.realQuantity}" pattern="#,##0.###"/></p></td>
            </tr>
            </c:forEach>
            </tbody>
        </c:if>    
        </table>
    </div>
</div>
</form>
</body>
</html>